package itsur.arquitecturas.implicitinvocation;

/**************************************************************************************
** Class name: Executive
** Author: A.J. Lattanze
** Date: 12/29/99
** Version 1.0
***************************************************************************************
** Abstract: This class acts as the system executive.  It provides the primary user
** interface.
**
**	1) List Students
**	2) List Courses
**	3) List Courses a Student has Registered for
**	4) List Students Registered for a Course
**	5) Register a Student for a Course
**	X) Exit
**
** Pseudo Code:
**
** 	add components that I want to receive my signals to the receiver list.
**
** 	do until done
**
** 		Present Menu
**		if user choice = 1 Send Event to listeners
**		if user choice = 2 Send Event to listeners
**		if user choice = 3 Send Event to listeners
**		if user choice = 4 Send Event to listeners
**		if user choice = 5 Send Event to listeners
**		if user choice = x you are done
**
** 	end do
**
** Modification Log
**************************************************************************************
** Modification by: A.J. Lattanze
** Date: 01/24/02
** Version 1.5
** Description: This class has been changed to run as a stand-alone thread. This
** method was changed to implement the Runnable class so that it could run as a thread.
** While, this has little impact on the architecture, it illustrates a multi-threaded
** event model.
**************************************************************************************
****************************************************************************************
** Modification by: ITSUR
** Date: 02/12/08
** Version 1.6
** Description: This class has been changed to add 3 new options:
**   - ListPendingCORECoursesComponent
**   - ListCoursesTakenComponent
**   - RegisterStudentIntelliSectionComponent
**************************************************************************************/

import java.util.*;

public class Executive extends Communication implements Runnable
{
	public Executive(Integer RegistrationNumber, String ComponentName )
	{
		super(RegistrationNumber, ComponentName );

	} // Exectutive

	public void run()
	{
	   char UserChoice;
	   boolean Done = false;
	   Menus Menu = new Menus();

	   AddToReceiverList( "ListStudentsComponent" );
	   AddToReceiverList( "ListCoursesComponent" );
	   AddToReceiverList( "ListCoursesRegisteredComponent" );
	   AddToReceiverList( "ListStudentsRegisteredComponent" );
	   AddToReceiverList( "RegisterStudentComponent" );
	   
	   
	   //ITSUR component
	   AddToReceiverList( "ListPendingCORECoursesComponent");
	   AddToReceiverList( "RegisterStudentIntelliSectionComponent");
	   
	   AddToReceiverList( "ListCoursesTakenComponent");

	   while( !Done )
	   {
			UserChoice = Menu.MainMenu();

			switch( UserChoice )
			{
			   case '1': SignalReceivers( "ListStudentsComponent" );
						 break;

			   case '2': SignalReceivers( "ListCoursesComponent" );
						 break;

			   case '3': SignalReceivers( "ListCoursesRegisteredComponent" );
						 break;

			   case '4': SignalReceivers( "ListStudentsRegisteredComponent" );
						 break;

			   case '5': SignalReceivers( "RegisterStudentComponent" );
						 break;

			   //ITSUR component
			   case '6': SignalReceivers( "ListPendingCORECoursesComponent" );
				 		 break;
			   case '7': SignalReceivers( "ListCoursesTakenComponent" );
		 		 break;
			   case '8': SignalReceivers( "RegisterStudentIntelliSectionComponent" );
		 		 break;
				

			   case 'X':
			   case 'x': Done = true;
			   			 SignalReceivers( SYSTEM_SHUT_DOWN );
						 break;

			} // switch

	   } // while

	} // run

} // class
